<template>
	<view class="ba-container">
		<view class="title-container">
			<view class="landmark-img">
				<image
					src="https://cdn8.axureshop.com/demo/1689476/images/%E7%BB%84%E4%BB%B6_%E8%A7%84%E8%8C%83/u1309.png">
				</image>
			</view>
			<view class="search-img">
				<image src="/static/icons/search.png"></image>
				<input type="text" class="search-img-input" placeholder="搜索机构/医生"  @confirm="searchHospital"  confirm-type="search"/>
			</view>
		</view>
		<view class="hospital-list">
			<template v-for="item in hospitalData" :key="item._id">
				<navigator :url="`/nearbyinstitutions/pages/Institutionslisthome/Institutionslisthome?_id=${item._id}`">
					<view class="hospital-item">
						<image :src="item.image"></image>
						<view class="hospital-info">
							<text>{{item.name}}</text>
							<view class="location">
								<text>距您3.6km</text>
							</view>
						</view>
						<image src="/static/right.png" class="to-details"></image>
					</view>
				</navigator>
			</template>

		</view>
	</view>

</template>

<script setup>
	import {
		onMounted,
		ref
	} from 'vue';
	import {
		getInstitutionslistApi
	} from '../../../api/Institutionslist';
	const inputValue = ref('');
	const hospitalData = ref([]);
	onMounted(() => {
		getInstitutionslist();
	});


	function searchHospital(event){
		// console.log(event.detail.value);
		getInstitutionslist({value:event.detail.value});
	}
	function getInstitutionslist(data) {
		getInstitutionslistApi(data).then(res => {
			if (res.code == 200) {
				hospitalData.value = res.data.rows;
			}
		})
	}
</script>

<style scoped lang="scss">
	.ba-container {
		min-height: 100vh;
		background-color: aliceblue;
	}

	.title-container {
		background-color: #ffffff;
		display: flex;
		align-items: center;
		padding: 0 34rpx;
		cursor: pointer
	}

	.landmark-img>image {
		width: 34rpx;
		height: 42rpx;
	}

	.search-img {
		margin-left: 20rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		width: 602rpx;
		height: 72rpx;
		border: 1px solid #cccccc;
		border-radius: 8px;
		margin-bottom: 10rpx;
	}

	.search-img>image {
		width: 32rpx;
		height: 32rpx;
	}

	.search-img-input {
		margin-left: 15rpx;
		width: 506rpx;
		height: 37rpx;
	}

	.hospital-list {
		padding: 0 34rpx;
		padding-top: 20rpx;
	}

	.hospital-item {
		padding: 0 25rpx;
		width: 620rpx;
		height: 228rpx;
		background-color: rgba(255, 255, 255, 1);
		box-shadow: 0px 0px 15px rgba(41, 132, 248, 0.0980392156862745);
		border-radius: 12px;
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 15rpx;
	}

	.hospital-item>image:first-child {
		margin-top: 10rpx;
		width: 160rpx;
		height: 160rpx;
	}

	.to-details {
		width: 20rpx;
		height: 28rpx;
	}

	.hospital-info {
		width: 356rpx;
	}

	.hospital-info>text {
		font-size: 32rpx;
		line-height: 56rpx;
	}

	.location>text {
		color: #999999;
		font-size: 24rpx;
	}
</style>